package 测试;

import java.util.*;

public class Main{
    public static void main(String[] args) {
        Set<Integer> set1 = new HashSet();
        Set<Integer> set2 = new HashSet();
        Set<Integer> set3 = new HashSet();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            set1.add(sc.nextInt());
        }
        while(sc.hasNext()){
            set2.add(sc.nextInt());
        }

        for(Integer set :set1){
            if(set2.equals(set)){
                set3.add(set);
            }
        }
        for(Integer set :set3){
            System.out.println(set);
        }
    }
}

 class Main3{
    public static void main(String[] args) {
        Map<Integer,Integer> map = new HashMap();
            for(int j = 2;j<100;j++){
                int temp = SearchTwo(j);
                if(temp>0){
                    map.put(j,temp);
                }
            }
        int start,end;
        Scanner sc = new Scanner(System.in);
        start = sc.nextInt();
        end = sc.nextInt();


        int rel = 0;
        while(true){
            if(end > 100){
                end-=100;
                rel+=20;
            }else{
                break;
            }
        }
        for(int i = start; i <= end; i++){
            rel+=map.get(i);
        }

        System.out.println(rel);
    }

    public static int SearchTwo(int num){
        int rel = 0;
        int temp;
        temp = num;
        temp/=10;
        int temp2 = temp*10 +2;
        if(temp==2){
            if(num == (temp2)){
                rel+=2;
                return rel;
            }
            rel++;
            return rel;
        }
        if(num%2==0){
            if(num == (temp2)){
                rel++;
            }
            return rel;
        }

        return rel;
    }
}
 class Main2 {
    public static void main(String[] args) {
        int start,end;
        Scanner sc = new Scanner(System.in);
        start = sc.nextInt();
        end = sc.nextInt();
        int rel = fun(start,end);
        System.out.println(rel);
    }
    public static int fun(int start, int end){
        int rel = 0;
        while(true){
            if(end > 100){
                end-=100;
                rel+=20;
            }else{
                break;
            }
        }
        for(int i = start; i <= end; i++){
            rel+=SearchTwo(i);
        }
        return rel;
    }
    public static int SearchTwo(int num){
        int rel = 0;
        int temp;
        temp = num;
        temp/=10;
        int temp2 = temp*10 +2;
        if(temp==2){
            if(num == (temp2)){
                rel+=2;
                return rel;
            }
            rel++;
            return rel;
        }
        if(num%2==0){
            if(num == (temp2)){
                rel++;
            }
            return rel;
        }

        return rel;
    }
}
